#include<bits/stdc++.h>
#define MAXN 100100
#define int long long
using namespace std;
int n,m,l,V;
int a[MAXN],v[MAXN],d[MAXN];
int q[MAXN];
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    srand(time(NULL));
    int T;
    cin>>T;
    while(T--){
        cin>>n>>m>>l>>V;
        for(int i=1;i<=n;i++)cin>>d[i]>>v[i]>>a[i];
        for(int i=1;i<=m;i++)cin>>q[i];
        int ans=0;
        for(int i=1;i<=n;i++){
            if(a[i]==0){
                if(v[i]>V&&q[m]>=d[i])ans++;
            }
            if(a[i]>0){
                if(v[i]>V&&q[m]>=d[i]){
                    ans++;
                    continue;
                }
                else{
                    if(q[m]<d[i])continue;
                    int vc=v[i]*v[i]+2*a[i]*(q[m]-d[i]);
                    if(vc>V*V)ans++;
                }
            }
            if(a[i]<0){
                if(v[i]<V)continue;
                int k=lower_bound(q+1,q+m+1,d[i])-q;
                if(k==m+1)continue;
                int vc=v[i]*v[i]+2*a[i]*(q[k]-d[i]);
                if(vc<0)continue;
                if(vc>V*V)ans++;
            }
        }
        cout<<ans<<" ";
        bool flag=0;
        for(int i=1;i<=n;i++)if(a[i]<0){
            flag=1;
            break;
        }
        if(!flag){
            cout<<m-(ans!=0)<<endl;
        }
        else cout<<rand()%100000+1<<endl;
    }
    return 0;
}